#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Autor: Josep Torrens Amer
# E-mail: toram74@gmail.com
#
# GNU GPL License, (C) 2007.
#
# Module: client
#
# Description: Modul base de classes objecte 
#
# Version: 0.0.1
#
# Created: 27-08-2007
#
# Modified:
#

 

class ClasseObjecte(Object):	
	"""
		Classe cObjecte
	"""
	
	def __init__ (self) :
		self.nom = ''
		

	def getParams (self):
		Params = []
		Param = {}
		
		for x in locals().keys():
				Param['camp'] = x
				Param['cond'] = '='
				Param['valor']  = locals()[x]
				append(Param)
		
		return Params
		
		
	def Grava (self) :
		"""
			Grava un objecte
		"""
			for x in self.getParams():
				camps += ', '+x['camp']
				if type(x['valor']) == type(2):
					valors += ', '+x['valor']
				else:
					valors += ", '"+x['valor']+"' "
			
			if camps.startwith(','):
				camps = camps[1:]
			if valors.startwith(','):
				valors = valors[1:]
			
			sql = "INSERT INTO %s (%s) VALUES (%s)  " % (self.nom, camps, valors)
			return db.executa(sql)
			
			
				
				
		

				
